package com.ruoyi.web.controller.Tour;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.TourCollect;
import com.ruoyi.system.service.ITourCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 收藏管理Controller
 *
 * @author once
 * @date 2020-10-02
 */
@RestController
@RequestMapping("/Tour/collect")
public class TourCollectController extends BaseController
{
    @Autowired
    private ITourCollectService tourCollectService;

    /**
     * 查询收藏管理列表
     */
    @PreAuthorize("@ss.hasPermi('Tour:collect:list')")
    @GetMapping("/list")
    public TableDataInfo list(TourCollect tourCollect)
    {
        startPage();
        List<TourCollect> list = tourCollectService.selectTourCollectList(tourCollect);
        return getDataTable(list);
    }

    /**
     * 导出收藏管理列表
     */
    @PreAuthorize("@ss.hasPermi('Tour:collect:export')")
    @Log(title = "收藏管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TourCollect tourCollect)
    {
        List<TourCollect> list = tourCollectService.selectTourCollectList(tourCollect);
        ExcelUtil<TourCollect> util = new ExcelUtil<TourCollect>(TourCollect.class);
        return util.exportExcel(list, "collect");
    }

    /**
     * 获取收藏管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('Tour:collect:query')")
    @GetMapping(value = "/{collectId}")
    public AjaxResult getInfo(@PathVariable("collectId") Long collectId)
    {
        return AjaxResult.success(tourCollectService.selectTourCollectById(collectId));
    }

    /**
     * 新增收藏管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:collect:add')")
    @Log(title = "收藏管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TourCollect tourCollect)
    {
        return toAjax(tourCollectService.insertTourCollect(tourCollect));
    }

    /**
     * 修改收藏管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:collect:edit')")
    @Log(title = "收藏管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TourCollect tourCollect)
    {
        return toAjax(tourCollectService.updateTourCollect(tourCollect));
    }

    /**
     * 删除收藏管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:collect:remove')")
    @Log(title = "收藏管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{collectIds}")
    public AjaxResult remove(@PathVariable Long[] collectIds)
    {
        return toAjax(tourCollectService.deleteTourCollectByIds(collectIds));
    }
}
